
	/********************************************************/
	/*                                                      */
	/*                                                      */
	/*         Copyright (C), 1993  SEIKO EPSON Corp.       */
	/*         ALL RIGHTS RESERVED                          */
	/*                                                      */
	/*                                                      */
	/*  file name : vsprintf.c                              */
	/*                                                      */
	/*  Revision history                                    */
	/*      93/12/17    first release       K.Shinozuka     */
    	/*      97/3/17	    modified	    	T.Katahira	*/
    	/*		change function declaration	    	*/
    	/*				to the ANSI style   	*/
	/*                                                      */
	/********************************************************/

#ifdef    UNIX
#include    "stdio.h"
#include    "stdarg.h"
#include    "smcvals.h"
#else
#include    <stdio.h>
#include    <stdarg.h>
#include    <smcvals.h>
#endif

extern int _doprint( /* _CODETYP, FILE *, unsigned char *, va_list */ );


#if defined( UNIX ) && !defined( ANSI )  /* for not ANSI C compiler */
int
vsprintf( va_alist )
va_dcl

#else
int
vsprintf( char *cDestP, const char *cFmtP, va_list tdArgP )
/*	char    *cDestP;            pointer to output string */
/*	const char    *cFmtP ;            pointer to the format string */
/*  va_list  tdArgP;            pointer to the list of the variable numbers of argument */

#endif

	/********************************************************/
	/*                                                      */
	/*  The vsprintf function writes output to the string   */
	/*  pointed to by cDestP.  The writing is controlled by */
	/*  output format ( cFmtP ), which specifies how        */
	/*  subsequent arguments are converted for output.      */
	/*  A null character is written at the end of the       */
	/*  characters written.                                 */
	/*  The format is composed of zero or more directives;  */
	/*  ordinary single byte characters ( not % ), which    */
	/*  are copied to the string; and conversion            */
	/*  specifications, each of which is started with the   */
	/*  character %.                                        */ 
	/*  About the specification of the conversion, please   */
	/*  read READMEstdio.                                   */
	/*  The vsprintf function returns when the end of the   */
	/*  format string is reached.                           */
	/*  If the format is exhausted while arguments remain,  */
	/*  the excess arguments are evaluated but not          */
	/*  converted.                                          */
	/*                                                      */
	/*  The vsprintf doesn't have following functions, which*/
	/*  prescribed in ANSI.                                 */
	/*                                                      */
	/*     1) p conversion                                  */
	/*     2) n conversion                                  */
	/*     3) g,G conversion                                */
	/*          g or G is treated as the same conversion as */
	/*          e or E respectively in this function.       */
	/*     4) treatment with long double values             */
	/*        ( L option )                                  */
	/*     5) limitation of character in the format         */
	/*          ANSI allows to use multibyte character      */
	/*          sequence, but we limit it only single byte  */
	/*          characters.                                 */
	/*                                                      */
	/*  note: Effective precision of a floating point number*/
	/*        is DBL_DIG + 1.  This function adds '0' after */
	/*        effective figures, if the value of precision  */
	/*        specified is too big.                         */
	/*        (DBL_DIG is defined in float.h)               */
	/*                                                      */
	/*      RETURN   the number of characters transmitted   */
	/*               not counting the terminating null      */
	/*               character                              */
	/*                                                      */
	/********************************************************/

    {
	 int      iChNum   ;          /* the number of characters transmitted */

#if defined( UNIX ) && !defined( ANSI )
	 char    *cDestP   ;          /* pointer to output string */
	 char    *cFmtP    ;          /* pointer to the format string */
	 va_list tdArgP    ;          /* pointer to the list of the variable numbers of argument */

	 va_start( tdArgP );
	 cDestP = va_arg( tdArgP, char * );
	 cFmtP = va_arg( tdArgP, char * );
	 tdArgP = *(va_list *)tdArgP;
#endif

	 iChNum = _doprint( _STR, cDestP, cFmtP, tdArgP );  /* write output to the string */
	 if( iChNum >= 0 ) {          /* success of writing */
	    cDestP[ iChNum ] = '\0';
	 } else {
	    cDestP[ 0 ] = '\0';
	 }
	 return( iChNum );
	}